package com.hecore.lagou.work;

import com.hecore.lagou.util.CommonSettingUtil;
import com.hecore.lagou.work.oneReducer.OneReducerMapper;
import com.hecore.lagou.work.oneReducer.OneReducerReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Job;

import java.io.IOException;


/**
 * @Author: hecore
 * @Date: 2020/10/19 00:49
 * @Description: 通过唯一的Reducer实现全局排序
 *  虽然没有设置制表符,但是效果是一样的.
 */

public class OneReducerDriver {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration config=new Configuration();
        Job job=Job.getInstance(config,"one-reducer");
        setJobConfig(job);
        String inputPath="F:/book/work/";
        String outPtah="F:/book/oneout";
        CommonSettingUtil.setLocalOut(job,inputPath,outPtah);
    }

    private static void setJobConfig(Job job) throws InterruptedException, IOException, ClassNotFoundException {
        job.setJarByClass(OneReducerDriver.class);
        job.setMapperClass(OneReducerMapper.class);
        job.setReducerClass(OneReducerReducer.class);
        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(IntWritable.class);
        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(IntWritable.class);
        job.setNumReduceTasks(1);
        job.setJobName("OneReduceSort");
    }

}
